﻿using System.ComponentModel;

namespace PLC
{
    /// <summary>
    /// PLC数据
    /// </summary>
    /// <typeparam name="T">读取的值类型</typeparam>
    public struct PLCData<T>
    {
        /// <summary>
        /// 字地址
        /// </summary>
        public int WordAddr { get; set; }
        /// <summary>
        /// 位地址
        /// </summary>
        public int BitAddr { get; set; }
        /// <summary>
        /// 功能
        /// </summary>
        public string Function { get; set; }
        /// <summary>
        /// 描述
        /// </summary>
        public string Info { get; set; }
        /// <summary>
        /// 数据类型
        /// </summary>
        public DataType DataType { get; set; }
        /// <summary>
        /// 高低位类型
        /// </summary>
        public HightLowType HightLowType { get; set; }
        /// <summary>
        /// 读取的值
        /// </summary>
        public T Data { get; set; }
    }

    /// <summary>
    /// 读取数据类型
    /// </summary>
    //public enum DataType
    //{
    //    /// <summary>
    //    /// 位
    //    /// </summary>
    //    Bit = 0,
    //    /// <summary>
    //    /// 短整型 16位
    //    /// </summary>
    //    Short,
    //    /// <summary>
    //    /// 整型 32位
    //    /// </summary>
    //    Int,
    //    /// <summary>
    //    /// 浮点 32位
    //    /// </summary>
    //    Float
    //}

    public enum DataType
    {
        [Description("Bool")]
        Bool,
        [Description("Short")]
        Short,
        [Description("Int")]
        Int,
        [Description("Float")]
        Float,
        [Description("Double")]
        Double,
        [Description("String")]
        String,
        [Description("ArrByte")]
        ArrByte,
        [Description("ArrFloat")]
        ArrFloat,
        [Description("ArrShort")]
        ArrShort,
        [Description("ArrUshort")]
        ArrUshort,
        [Description("ArrInt")]
        ArrInt,
        [Description("ArrUint")]
        ArrUint,


    }

    public enum HightLowType
    {
        _12,
        _21,
        _4321
    }
}
